﻿@model WeekWinProject
<div class="main">
    <div class="b-all-1">
        <table>
            <tr>
                <td class="b-all-left">
                    <div></div>
                    <table>
                        <tr class="detail-item">
                            <td colspan="4">
                                <div class="mt20">
                                    <em class="fr gray f16">@Model.ProjectNumber</em>
                                    <b class="f20">周周盈</b>
                                </div>
                                <div class="ddw_op clearfix">
                                    <ul>
                                        <li>
                                            <div style="padding-top:7px;" class="t1"><em class="orange" style="font-size:30px;">@Model.TotalTrade.MoneyFormat()</em>元</div>
                                            <div style="padding-top:7px;" class="t2">总操盘资金</div>
                                        </li>
                                        <li class="opd"></li>
                                        <li>
                                            <div class="t1"><em class="orange f20">@Model.FirmCapital.MoneyFormat()</em>元</div>
                                            <div class="t2">实盘资金</div>
                                        </li>
                                        <li class="opj"></li>
                                        <li>
                                            <div class="t1"><em class="orange f20">@Model.RiskMargin.MoneyFormat()</em>元</div>
                                            <div class="t2">
                                                风险保证金
                                                <span class="info-prompt"></span>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                        <tr class="detail-item">
                            <td class="wth120">亏损警戒线</td>
                            <td><span class="orange f20">@Model.LossWarLine.MoneyFormat()</span><span class="f12">元</span><span class="info-prompt"></span></td>
                            <td class="wth120">亏损平仓线</td>
                            <td><span class="red f20">@Model.LossOpenLine.MoneyFormat()</span><span class="f12">元</span><span class="info-prompt"></span></td>
                        </tr>
                        <tr class="detail-item">
                            <td>开始交易时间</td>
                            <td>@(Model.StartProjectTime.ToString("yyyy-MM-dd"))</td>
                            <td>已交易天数</td>
                            <td><span class="black f20">@(DateTime.Now.DateDiff(Model.StartProjectTime))</span>天</td>
                        </tr>
                        <tr class="detail-item">
                            <td>投资方向</td>
                            <td>沪深A股</td>
                            <td>仓位要求</td>
                            <td>@MathProject.PositionLimits(Model.FirmCapital)</td>
                        </tr>
                        <tr class="detail-item">
                            <td>盈利分配</td>
                            <td>盈利七成归您</td>
                            <td>账户管理费</td>
                            <td>完全免费</td>
                        </tr>
                    </table>
                </td>
                <td class="b-all-right">
                    <div class="agreement">
                        <a class="blue" href="#">周周盈合作操盘协议</a>
                    </div>
                    <div class="auto">
                        <div class="pan">
                            @CommonFunc.GetProjectStateDetail(Model.ProjectState)
                        </div>
                        @if (Model.ProjectState >= (int)ProjectStateEnum.Trading)
                        {
                            <div class="money">
                                保证金总投入：<em class="f20">@Model.RiskMargin</em>元<span class="info-prompt"></span>
                            </div>
                            if (ViewData["WeekWinProjectRiskMargin0"] != null)
                            {
                                var weekWinProjectRiskMargins0 = (List<WeekWinProjectRiskMargin>)ViewData["WeekWinProjectRiskMargin0"];
                                foreach (var item in weekWinProjectRiskMargins0)
                                {
                                    <div class="money">
                                        追加保证金<em class="f20">@item.AddMoney</em>元<span>取消</span>
                                    </div>
                                }
                            }
                            <div class="mt20">
                                <input type="button" id="BtnAddRiskMargin" class="button grey" value="追加保证金" />
                            </div>
                            <div class="mt20">
                                <input type="button" id="BtnTradingAccount" class="button grey" value="交易账号" style="margin-right: 15px;" />
                                <input type="button" id="BtnTermination" class="button red" value="终止操盘" />
                            </div>

                            <script type="text/javascript">
                                $(function() {
                                    $("#BtnAddRiskMargin").bind("click", function() {
                                        $.StockWindow({
                                            title: "追加保证金",
                                            id: "AddRiskMarginWindow",
                                            width: 500,
                                            content: '<div class="db-m">' +
                                                '<div class="db-tips">' +
                                                '<span class="icon icon-warning"></span>' +
                                                '<div class="tips">每次追加保证金不能小于当前方案总操盘资金的1%，最低100元，且每天最多追加5次(包括取消次数)。</div>' +
                                                '</div>' +
                                                '<div class="db-con">' +
                                                '<div style="padding:20px 0;" class="ui-sub-form">' +
                                                '<label class="ui-label">追加金额</label><input id="InputRiskMargin" type="text" style="width:150px;" class="ui-input" />' +
                                                '<label class="fl" style="margin:3px 0 0;">元</label>' +
                                                '<label class="fl gray" style="margin:3px 10px;">最少100元</label>' +
                                                '</div>' +
                                                '<div style="padding:20px 0 10px 100px;" class="ui-sub-form">' +
                                                '<input type="button" id="Window-BtnConfirm" value="确定追加" class="button red">' +
                                                '<input type="button" id="Window-BtnCancel" value="取消追加" class="button grey">' +
                                                '</div>' +
                                                '</div>' +
                                                '</div>',
                                            callback:function() {
                                                $("#Window-BtnConfirm").bind("click", function () {
                                                    var $InputRiskMargin = $("#InputRiskMargin");
                                                    var inputRiskMargin = $InputRiskMargin.val();
                                                    if (!$.trim(inputRiskMargin)) {
                                                        $.jalert("请填写追加金额");
                                                        $InputRiskMargin.focus();
                                                        return;
                                                    }
                                                    inputRiskMargin = $.trim(inputRiskMargin);
                                                    var reg = /^\d{1,}$/;
                                                    if (!reg.test(inputRiskMargin)) {
                                                        $.jalert("追加金额填写错误，金额必须是整数");
                                                        $InputRiskMargin.focus();
                                                        return;
                                                    }
                                                    inputRiskMargin = parseInt(inputRiskMargin);
                                                    if (inputRiskMargin<100) {
                                                        $.jalert("追加的保证金金额不能小于100元");
                                                        $InputRiskMargin.focus();
                                                        return;
                                                    }
                                                    $.jajax({
                                                        url: "@Url.DomainRouteUrl(AreasConfig.Web, new { controller = "WeekWin", action = "AddRiskMargin" })",
                                                        params: { projectId: @Model.ProjectId, riskMargin: inputRiskMargin, type: 1 },
                                                        callback: function(ret) {
                                                            if (ret) {
                                                                $.jalert(ret.message);
                                                                if (ret.data > 0) {
                                                                    window.location.reload();
                                                                }
                                                            }
                                                        }
                                                    });
                                                });
                                                $("#Window-BtnCancel").bind("click", function () {
                                                    $("#AddRiskMarginWindow").CloseWindow();
                                                });
                                            }
                                        });
                                    });
                                    $("#BtnTradingAccount").bind("click", function() {
                                        var $tabTitle = $(".tabTitle").find("span");
                                        $tabTitle.removeClass("select");
                                        $tabTitle.filter("[tag=TradingAccount]").addClass("select");
                                        $(".tabsub[mark]").hide();
                                        $(".tabsub[mark=TradingAccount]").show();
                                    });
                                    $("#BtnTermination").bind("click", function () {
                                        $.StockWindow({
                                            title: "申请终止操盘",
                                            id: "TerminationWindow",
                                            width:500,
                                            content: '<div class="db-m">' +
                                                '<div class="db-confirm">' +
                                                '<span class="db-icon db-icon-help"></span>' +
                                                '<div class="tips" style="width:85%;">' +
                                                '<p>您确定要申请完结方案吗</p><br/>' +
                                                '<p class="red">请确保您的交易账户股票已经全部卖出，否则我们将有权把您的股票进行平仓处理（不保证平仓价格）</p>' +
                                                '</div>' +
                                                '</div>' +
                                                '<div class="db-con">' +
                                                '<div style="padding:20px 0 10px 100px;" class="ui-sub-form">' +
                                                '<input type="button" id="Window-BtnConfirm" value="确定" class="button red">' +
                                                '<input type="button" id="Window-BtnCancel" value="取消" class="button grey">' +
                                                '</div>' +
                                                '</div>' +
                                                '</div>',
                                            callback:function() {
                                                $("#Window-BtnConfirm").bind("click", function () {

                                                });
                                                $("#Window-BtnCancel").bind("click", function () {
                                                    $("#TerminationWindow").CloseWindow();
                                                });
                                            }
                                        });
                                    });

                                });
                            </script>
                        }
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="tabpage">
        <div class="tabTitle">
            <span tag="ProjectRiskMargin">方案资金记录</span>
            @if (Model.ProjectState >= (int)ProjectStateEnum.Trading)
            {
                <span tag="TradingAccount">股票交易账户</span>
            }
        </div>
        <div class="tabcon">
            @{
                WeekWinProjectRiskMargins weekWinProjectRiskMargins = new WeekWinProjectRiskMargins();
                if (ViewData["WeekWinProjectRiskMargin"] != null)
                {
                    weekWinProjectRiskMargins = (WeekWinProjectRiskMargins)ViewData["WeekWinProjectRiskMargin"];
                }

                <div class="tabsub" mark="ProjectRiskMargin">
                    <table>

                        <tr>
                            <td class="tabcon-left">
                                <table class="mb20">
                                    <tr>
                                        <th class="left wth100">时间</th>
                                        <th class="wth250">类型</th>
                                        <th class="wth250">资金</th>
                                        <th>状态</th>
                                    </tr>
                                    @if (weekWinProjectRiskMargins.Items.Count <= 0)
                                    {
                                        <tr>
                                            <td style="height: 40px; line-height: 40px; text-align: center" colspan="4">暂无记录</td>
                                        </tr>
                                    }
                                    else
                                    {
                                        foreach (var item in weekWinProjectRiskMargins.Items)
                                        {
                                            <tr>
                                                <td class="left f16">@item.AddTime.ToString("yyyy-MM-dd")</td>
                                                <td>@(item.Type == 0 ? "减保证金" : "加保证金")</td>
                                                <td><span class="f16">@item.AddMoney</span>元</td>
                                                <td>@(item.AddState == 1 ? "等待处理" : "通过")</td>
                                            </tr>
                                        }
                                    }
                                    </table>
                                </td>
                            </tr>

                        </table>
                    </div>
            }


            @if (Model.ProjectState >= (int)ProjectStateEnum.Trading)
            {
                <div class="tabsub" mark="TradingAccount" style="display: none;">
                    <div class="contents">
                        重点提醒：交易前请先阅读<a class="red" target="_blank" href="@Url.DomainRouteUrl(AreasConfig.Web, new {controller = "help", action = "daywin"})">《周周盈规则说明》</a>
                        <a target="_blank" href="#" class="red">《今日限制股》</a>
                        <br>
                        资金风控：亏损警戒线 <span class="red">@Model.LossWarLine</span> 元，亏损平仓线 <span class="red">@Model.LossOpenLine</span> 元<br>
                        交易账户：@Model.TradingAccount &nbsp;
                        <br>
                        交易密码：@Model.TradingPassword（为了您的资金安全，请妥善保管好密码）&nbsp;
                        <br>
                        交易软件：<a target="_blank" href="#">Homs钱江版（独立）</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="red">←下载时一定要选择正确的交易软件哦！</span>
                    </div>
                </div>
            }
        </div>
    </div>
</div>



<script type="text/javascript">
    $(function () {
        var $tabTitle = $(".tabTitle").find("span");
        $tabTitle.bind("click", function () {
            var $this = $(this);
            var tag = $this.attr("tag");
            $tabTitle.removeClass("select");
            $this.addClass("select");
            $(".tabsub[mark]").hide();
            $(".tabsub[mark=" + tag + "]").show();
        });

    });
</script>